const cloud = require('wx-server-sdk');

cloud.init({
  env: cloud.DYNAMIC_CURRENT_ENV
});

const db = cloud.database();

// 创建集合云函数入口函数
exports.main = async (event, context) => {
  try {
    // 创建集合
    // await db.createCollection('personalKeyInformation');
    console.log(event.data)
    await db.collection('workExperience').doc(event.data._id).update({
      // data 字段表示需新增的 JSON 数据
      data:{
        companyText: event.data.companyText,
        postText: event.data.postText,
        entryText: event.data.entryText,
        resignText: event.data.resignText,
        workContent: event.data.workContent,
      }
    });
    return {
      success: true
      // data: event.data
    };
    } catch (e) {
      return {
        success: false,
        errMsg: e
      };
  }
};

